﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Server
{
    class CreateUser
    {
        //Properties
        const int MinUsernameLength = 2;
        const int MinPasswordLength = 6;

        public bool isUsernameValid;
        public bool isPasswordValid;

        //Metoder
        public bool IsUsernameValidForCreation(string UsernameIn)
        {
            if (string.IsNullOrWhiteSpace(UsernameIn))
            {
                throw new ArgumentNullException("Username cannot be empty or whitespace");
            }
            else if (UsernameIn.Length < MinUsernameLength)
            {
                throw new ArgumentException("Username is too short - must be at least " + MinUsernameLength + " long");
            }
            else isUsernameValid = true;
            return isUsernameValid;
        }
        public bool IsPasswordValidForCreation(string PasswordIn)
        {
            if (string.IsNullOrWhiteSpace(PasswordIn))
            {
                throw new ArgumentNullException("Password cannot be empty or whitespace");
            }
            else if (PasswordIn.Length < MinPasswordLength)
            {
                throw new ArgumentOutOfRangeException("Password has to be at least " + MinPasswordLength + " long");
            }
            else isPasswordValid = true;
            return isPasswordValid;
        }
    }
}
